﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Composite.Regions;

using UserLoginModule.Views.UserLoginView;
using UserLoginModule.Controllers;
using ELMWCFServiceClass.ELMWCF;
using ELMApplication.Common.Const;
using UserLoginModule.Views.AddUserView;
using UserLoginModule.Views.AddMatterView;

namespace UserLoginModule
{
    public class UserLoginModule:IModule
    {
        private readonly IUnityContainer container;
        private readonly IRegionManager regionManager;
        public UserLoginModule(IUnityContainer container, IRegionManager regionManager)
        {
            this.regionManager = regionManager;
            this.container = container;
        }

        #region IModule Members

        public void Initialize()
        {
            registerViewsAndServices();
            regionManager.RegisterViewWithRegion("MainRegion", () => container.Resolve<IUserLoginPresentationModel>().View);
            regionManager.RegisterViewWithRegion(RegionNames.NewUser.ToString(), () => container.Resolve<IAddUserPrentationModel>().View);
            regionManager.RegisterViewWithRegion(RegionNames.NewMatter.ToString(), () => container.Resolve<IAddMatterPrentationModel>().View);

            // regionManager.Regions[RegionNames.MainRegion.ToString()].Add(container.Resolve<IUserLoginPresentationModel>().View, "UserLoginView");
        }

        protected void registerViewsAndServices()
        {

            container.RegisterType<ILoginCommand,LoginCommand>();
            container.RegisterType<ELMServiceClient>(new InjectionConstructor());
            container.RegisterType<IUserLoginView,UserLoginView>();
            container.RegisterType<IUserLoginPresentationModel, UserLoginPrentationModel>();
            container.RegisterType<IAddUserView, AddUserView>();
            container.RegisterType<IAddUserPrentationModel, AddUserPrentationModel>();
            container.RegisterType<IAddMatterView, AddMatterView>();
            container.RegisterType<IAddMatterPrentationModel, AddMatterPrentationModel>();


        }


        #endregion
    }
}
